﻿using BaiTu.IOCServices;
using BaiTu.IQueueService;
using BaiTu.Logging;
using BaiTu.QueueEntity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

using BaiTu.ILogging;
namespace BaiTu.QueueLogging
{
    /// <summary>
    /// 通过队列实现的日志处理
    /// </summary>
    public class QueueLoggingService
    {
        public ILogger Logger { get; set; }
        private IQueue queue = null;

        public QueueLoggingService()
        {
            queue = EngineContext.Current.Resolve<IQueue>();

            queue.CreateIfNotExists<Framework.Exceptions.BaiTuSerializedException>();
            Logger = NullLogger.Instance;
        }
        public void Starter()
        {
            QueueLoggingProcessor qp = new QueueLoggingProcessor()
            {
                Logger = Logger
            };
            ThreadPool.QueueUserWorkItem(new WaitCallback(qp.Process));


        }
        //  qp.Process(null);

        //ThreadPool.QueueUserWorkItem(new WaitCallback(qp.Process));

    }
}
